/*
 * @Author: ZhangXingliang
 * @Date: 2021-11-19 15:30:12
 * @Last Modified by:   ZhangXingliang
 * @Last Modified time: 2021-11-19 15:30:12
 */

/**
 *
 * 毛玻璃
 * @export
 * @param {ImageData} imageData
 * @return {*}  {ImageData}
 */
export default function invertColors(imageData: ImageData): ImageData {
  let newImageData = new ImageData(imageData.width, imageData.height)
  for (let i = 0; i < imageData.data.length / 4; i++) {
    let realIndex = i * 4
    newImageData.data[realIndex] = 255 - imageData.data[realIndex]
    newImageData.data[realIndex + 1] = 255 - imageData.data[realIndex + 1]
    newImageData.data[realIndex + 2] = 255 - imageData.data[realIndex + 2]
    newImageData.data[realIndex + 3] = imageData.data[realIndex + 3]
  }
  return newImageData
}
